Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class PHIEUTHUBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As PHIEUTHUDto)
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDPHIEUTHU As System.Int32)
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.xoa(IDPHIEUTHU)
 End Sub
 Public Sub sua(ByVal Dto As PHIEUTHUDto)
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHIEUTHU As PHIEUTHUdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHIEUTHU)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaMAPHIEUTHU( ByVal MAPHIEUTHU as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaMAPHIEUTHU(MAPHIEUTHU,IDPHIEUTHU)
 End Sub 
 Public Sub suaIDHOCSINH( ByVal IDHOCSINH as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaIDHOCSINH(IDHOCSINH,IDPHIEUTHU)
 End Sub 
 Public Sub suaIDLOPHOC( ByVal IDLOPHOC as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaIDLOPHOC(IDLOPHOC,IDPHIEUTHU)
 End Sub 
 Public Sub suaNGAYBATDAU( ByVal NGAYBATDAU as System.DateTime, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaNGAYBATDAU(NGAYBATDAU,IDPHIEUTHU)
 End Sub 
 Public Sub suaTONGTIENPHAIDONG( ByVal TONGTIENPHAIDONG as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaTONGTIENPHAIDONG(TONGTIENPHAIDONG,IDPHIEUTHU)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDPHIEUTHU)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDPHIEUTHU As System.Int32 )
 Dim dao As New PHIEUTHUDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDPHIEUTHU)
 End Sub 
 Public Function LayBangTable( ByVal IDPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(IDPHIEUTHU,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDPHIEUTHU As System.Int32) As IList
 Dim Dao As New PHIEUTHUDao(IDPHIEUTHU,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHIEUTHU As PHIEUTHUdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHIEUTHU)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDPHIEUTHU (ByVal IDPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDPHIEUTHU(IDPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHIEUTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDPHIEUTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHIEUTHU (ByVal IDPHIEUTHU As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoIDPHIEUTHU(IDPHIEUTHU)
 End sub
 Public Function LayBangTableTheoMAPHIEUTHU (ByVal MAPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoMAPHIEUTHU(MAPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoMAPHIEUTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoMAPHIEUTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoMAPHIEUTHU (ByVal MAPHIEUTHU As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoMAPHIEUTHU(MAPHIEUTHU)
 End sub
 Public Function LayBangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(IDHOCSINH)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDHOCSINH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDHOCSINH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDHOCSINH (ByVal IDHOCSINH As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoIDHOCSINH(IDHOCSINH)
 End sub
 Public Function LayBangTableTheoIDLOPHOC (ByVal IDLOPHOC As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDLOPHOC(IDLOPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDLOPHOC (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDLOPHOC(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDLOPHOC (ByVal IDLOPHOC As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoIDLOPHOC(IDLOPHOC)
 End sub
 Public Function LayBangTableTheoNGAYBATDAU (ByVal NGAYBATDAU As System.DateTime) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGAYBATDAU(NGAYBATDAU)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGAYBATDAU(ByVal NGAYBATDAU1 As System.DateTime,ByVal NGAYBATDAU2 As System.DateTime ) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGAYBATDAU(NGAYBATDAU1 ,NGAYBATDAU2)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGAYBATDAU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGAYBATDAU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoNGAYBATDAU (ByVal NGAYBATDAU As System.DateTime) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoNGAYBATDAU(NGAYBATDAU)
 End sub
 Public Function LayBangTableTheoTONGTIENPHAIDONG (ByVal TONGTIENPHAIDONG As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoTONGTIENPHAIDONG(TONGTIENPHAIDONG)
 Return Dao
 End Function
 Public Function LayBangTableTheoTONGTIENPHAIDONG (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoTONGTIENPHAIDONG(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTONGTIENPHAIDONG (ByVal TONGTIENPHAIDONG As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoTONGTIENPHAIDONG(TONGTIENPHAIDONG)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDPHIEUTHU As System.Int32) As PHIEUTHUdto
 Dim Dao As New PHIEUTHUDao(IDPHIEUTHU, ketnoi)
 Dim dto As New PHIEUTHUdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(0)("IDPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(0)("PHIEUTHU.IDPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(0)("MAPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(0)("PHIEUTHU.MAPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(0)("PHIEUTHU.IDHOCSINH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(0)("IDLOPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(0)("PHIEUTHU.IDLOPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("NGAYBATDAU")) = False Then
 Dto.NGAYBATDAU = Dao.Rows(0)("NGAYBATDAU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.NGAYBATDAU")) = False Then
 Dto.NGAYBATDAU = Dao.Rows(0)("PHIEUTHU.NGAYBATDAU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TONGTIENPHAIDONG")) = False Then
 Dto.TONGTIENPHAIDONG = Dao.Rows(0)("TONGTIENPHAIDONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.TONGTIENPHAIDONG")) = False Then
 Dto.TONGTIENPHAIDONG = Dao.Rows(0)("PHIEUTHU.TONGTIENPHAIDONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("PHIEUTHU.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHIEUTHU.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("PHIEUTHU.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As PHIEUTHUdto
 Dim dto As New PHIEUTHUdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(i)("IDPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(i)("PHIEUTHU.IDPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(i)("MAPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(i)("PHIEUTHU.MAPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.IDHOCSINH")) = False Then
 Dto.IDHOCSINH = Dao.Rows(i)("PHIEUTHU.IDHOCSINH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(i)("IDLOPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(i)("PHIEUTHU.IDLOPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("NGAYBATDAU")) = False Then
 Dto.NGAYBATDAU = Dao.Rows(i)("NGAYBATDAU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.NGAYBATDAU")) = False Then
 Dto.NGAYBATDAU = Dao.Rows(i)("PHIEUTHU.NGAYBATDAU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TONGTIENPHAIDONG")) = False Then
 Dto.TONGTIENPHAIDONG = Dao.Rows(i)("TONGTIENPHAIDONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.TONGTIENPHAIDONG")) = False Then
 Dto.TONGTIENPHAIDONG = Dao.Rows(i)("PHIEUTHU.TONGTIENPHAIDONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("PHIEUTHU.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHIEUTHU.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("PHIEUTHU.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As PHIEUTHUdto
 Dim dto As New PHIEUTHUdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New PHIEUTHUDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

